package com.ywy.dao;

import com.ywy.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

/**
 * 用户Repository接口
 *
 * @author ywy
 * @date 2022/8/26 9:13
 */
public interface UserDao extends JpaRepository<User, Integer>, JpaSpecificationExecutor<User> {
    /**
     * 根据用户名查找用户实体
     *
     * @param username
     * @return
     */
    @Query(value = "select * from sys_user where username=?1", nativeQuery = true)
    User getByUsername(String username);

    /**
     * 根据邮箱查找用户实体
     *
     * @param email
     * @return
     */
    @Query(value = "select * from sys_user where email=?1", nativeQuery = true)
    User getByEmail(String email);
}
